// 导入express
const express = require('express')
// 导入
const expressJoi = require('@escook/express-joi')
// 导入文章发布验证规则对象
const {
  reg_article_scchema,
  reg_deleteArticle_schema,
  reg_getArticle_schema,
  reg_getArticleById_schema,
  red_updateArticle_shema
} = require('../schema/acticle')
// 导入 发布文章路由 对应处理函数模块
const {
  addArticle,
  getArticle,
  deleteArticle,
  getArticleById,
  updateArticleInfo
} = require('../router_handler/article_handler')

// 创建路由对象
const router = express.Router()

// 定义路由
// 文章发布路由
router.post('/addarticle', expressJoi(reg_article_scchema), addArticle)

// 根据id获取文章信息
router.get(
  '/getArticleInfo',
  expressJoi(reg_getArticleById_schema),
  getArticleById
)

// 文章列表路由
router.get('/articlelist', expressJoi(reg_getArticle_schema), getArticle)

// 修改文章信息路由
router.post('/updateArticle', expressJoi(red_updateArticle_shema), updateArticleInfo)

// 删除文章路由
router.post(
  '/deletearticle',
  expressJoi(reg_deleteArticle_schema),
  deleteArticle
)

// 向外暴露 路由对象
module.exports = router
